/**
 * @(#)Shot.java
 *
 *
 * @author 
 * @version 1.00 2009/12/10
 */

import java.util.*;
import java.awt.geom.*;
public class Shot 
{
	//protected static final int VELOCITY = 15;
	protected static final int LENGTH = 10;
	protected double xPosition;
	protected double yPosition;
	protected double heading;
	protected double xVelocity;
	protected double yVelocity;
	protected Line2D 	shotShape;
	protected double velocity;
	//private boolean invincible;


    public Shot(double newHeading, double startX, double startY, double velocity) 
    {
    	heading = newHeading;
    	this.velocity = velocity;
    	xPosition = startX;
    	yPosition = startY;
    	xVelocity = velocity * Math.sin(heading);
    	yVelocity = velocity * Math.cos(heading);
    	shotShape = new Line2D.Double(xPosition - LENGTH * Math.sin(heading), yPosition + LENGTH * Math.cos(heading), xPosition, yPosition);
    }
    
    public void Update()
    {
    	//System.out.println(xPosition + " " + yPosition);
    	if(heading > 2*Ship.PI)
    	{
    		heading -= 2* Ship.PI;
    	}
    	else if(heading < -2*Ship.PI)
    	{
    		heading += 2*Ship.PI;
    	}
    	xPosition+=xVelocity;
    	yPosition-=yVelocity;
    	shotShape = new Line2D.Double(xPosition - LENGTH * Math.sin(heading), yPosition + LENGTH * Math.cos(heading), xPosition, yPosition);
    }
    
    public Line2D getShotShape()
    {
    	return shotShape;
    }
    
    public Point2D.Double getPositionPoint()
    {
    	return new Point2D.Double(xPosition, yPosition);
    }
    	
    
    
}